﻿@using Texts = MvcTemplate.Resources.Views.Administration.Accounts.AccountView.Texts
@using MvcTemplate.Resources.Views.Auth.AccountLoginView

@model AccountLoginView

<div class="title text">@Pages.AuthLogin</div>
<div class="separator"></div>

<form asp-antiforgery="true">
    @Html.Partial("_AuthAlerts")
    <div class="auth-content">
        <div class="input-group">
            <span class="fa fa-user"></span>
            <input asp-for="Username" placeholder="@Titles.Username" autocomplete="off" />
            <span class="input-error fa fa-exclamation-triangle"></span>
        </div>
        <div class="input-group">
            <span class="fa fa-lock"></span>
            <input asp-for="Password" type="password" placeholder="@Titles.Password" autocomplete="off" />
            <span class="input-error fa fa-exclamation-triangle"></span>
        </div>
        @{ ILanguages languages = Context.RequestServices.GetService<ILanguages>(); }
        @{ String returnPath = ViewContext.HttpContext.Request.Query["returnUrl"]; }
        @{ String rootPath = Context.Request.PathBase.Value.Trim('/'); }
        @{ returnPath = (returnPath ?? rootPath).Trim('/'); }

        @if (languages.Supported.Length > 1 && returnPath == rootPath)
        {
            <div class="input-group">
                <div class="language-container dropdown-toggle" data-toggle="dropdown">
                    <span class="current-language">
                        <img src="@Url.Content($"~/Images/Flags/{languages.Current.Abbreviation}.gif")" width="16" height="11" alt="">
                        @languages.Current.Name
                    </span>
                    <span class="caret"></span>
                </div>
                <ul class="dropdown-menu" role="menu">
                    @foreach (Language language in languages.Supported)
                    {
                        <li>
                            <a class="dropdown-item" href="@Url.Action("Login", new { language = language.IsDefault ? "" : language.Abbreviation })">
                                <img src="@Url.Content($"~/Images/Flags/{language.Abbreviation}.gif")" width="16" height="11" alt="">
                                @language.Name
                            </a>
                        </li>
                    }
                </ul>
            </div>
        }
    </div>
    <button type="submit" class="btn btn-primary">@Actions.Login</button>
</form>

<div class="separator"></div>
<div class="auth-actions">
    <a asp-action="Recover" class="text fa fa-unlock" data-toggle="tooltip" data-original-title="@Texts.LostPassword" data-placement="bottom"></a>
</div>
